<?php

// $Id: stats.php 3 2010-05-27 16:25:49Z alistair.mills@btinternet.com $

   session_start();

include ("functions.php");

   $thisscript = $HTTP_SERVER_VARS["PHP_SELF"]; // link to this php file
   $path_parts = pathinfo($thisscript);
   $root_dir   = $path_parts["dirname"];
   $host       = "http://".$HTTP_SERVER_VARS['SERVER_NAME'];

   if (isset($_SESSION["history"])) {
       $history = $_SESSION["history"];
   }  else {
       $_SESSION["history"] = $history;
   }

   $sort = "";
   if ($_SERVER['REQUEST_METHOD'] == "GET") {
       if (isset($_GET["sort"])) $sort = $_GET["sort"];
   }

   $dir = "";
   if ($_SERVER['REQUEST_METHOD'] == "GET") {
       if (isset($_GET["dir"])) $dir = $_GET["dir"];
   }

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

    <meta name="description" content="French Lessons">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Articles de La Guinguette - Statistiques <?php $s = ($sort == "") ? "" : " x " . $sort; $d = ($dir == "") ? "" : " : " . $dir; echo "$s $d "; ?></title>
    <link href="../../style.css" rel="stylesheet" type="text/css">

    <style type="text/css">
<!--
p {
    color: Black;
}
-->
    </style>

</head>


<body bgcolor="#FFFFFF" background="../back.gif" text="#008000" link="#0000FF" vlink="#0000FF">
<a href="./index.html"><img src="../../up.gif" alt="up" width="36" height="18"></a>
<h1>Articles de La Guinguette - Statistiques </h1>
<br>
<a title="chercher" href="_zoom/search.php">Chercher les traductions</a><br>
<a title="Articles de La Guinguette &agrave; traduire" href="traductions.html">Articles de La Guinguette &agrave; traduire</a><br>
<a title="articles" href="index.php">Articles</a><br><br>
<p>Cliquer sur le titre d'un colon pour tirer les donn&eacute;es du tableau.</p>

<?php

    $db = db_open($host);

    if ($db) {

       $translators = build_index ("SELECT * FROM translators","trans", "translator" );
       $months      = build_index ("SELECT * FROM months",     "mon",    "month" );
       $categories  = build_index ("SELECT * FROM categories", "cat",    "category" );

       $sql = ($sort == "") ?
          "SELECT * FROM statistics"
       :
          "SELECT * FROM statistics ORDER BY " . $sort. " " . $dir
       ;

       $dir      = ( $dir == "DESC") ? "" : "DESC";
       $up       = ( $dir == "DESC") ? "^" : "v";
       $down     = ( $up  == "^")    ? "v" : "^";

       $sql_       = addslashes($sql);
       $sql__      = get_magic_quotes_runtime() ? $sql_ : $sql;
       $reponse    = mysql_query($sql__) or die(mysql_error());
       $first_time = true;

       echo '<table border="1">';

       while ($un_film = mysql_fetch_assoc($reponse)) {
          if ($first_time) {
             echo '<tr>';
             foreach ($un_film as $champ => $contenu) {
                 echo '<td><a href="stats.php?sort=' . $champ . '&amp;dir=' . $dir . '"     title="trier par ' . $champ . '"> '  . $champ       . ' ' . $up . '</a></td>';
             }

             echo '</tr>';
             $first_time = false;
          }

          echo '<tr>';
          foreach ($un_film as $champ => $contenu) {
              $show = $contenu;
              $show = "$champ" == "translator" ? $translators[$contenu] : $show;
              echo '<td>' . $show . '</td>';
          }
          echo '</tr>';
       }

       echo '</table>';
       mysql_free_result($reponse);
    }

?>

<hr>
      <p lang="ENS">With questions or for more information, please contact Alistair Mills <a href="mailto:alistair.mills@btinternet.com"> alistair.mills@btinternet.com</a><br>
      Updated <!-- #BeginDate format:Sw1 --> Sunday 13th April 2008 <!-- #EndDate --></p>
      <hr>
      <a href="http://validator.w3.org/check?uri=referer">
        <img
        src="http://www.w3.org/Icons/valid-html401-blue"
        alt="Valid HTML 4.01 Transitional" height="31" width="88">
      </a>
<hr>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2273668-1";
urchinTracker();
</script>

</body>
</html>
